package main

import (
	"go-ms-scaffold/consul/service_register"
	"log"

	"github.com/gin-gonic/gin"
)

func main() {
	host := "127.0.0.1"
	port := 8500
	registryDiscoveryClient, _ := service_register.NewConsulServiceRegister(host, port, "")
	serviceInstanceInfo, _ := service_register.NewServiceInstance(
		"sanpangzi-simple",
		"",
		8090,
		false,
		map[string]string{"user": "daxiongjun"},
		"",
	)
	registryDiscoveryClient.Register(serviceInstanceInfo)
	s, error := registryDiscoveryClient.GetInstances("sanpangzi-simple")
	if error != nil {
		log.Fatal("register service error")
		return
	}
	log.Println(s)
	r := gin.Default()

	r.GET("/consul/health", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})
	r.Run(":8090")

}
